package com.company.card_service.api;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.company.card_service.serviceImpl.EmployeeViewServiceImpl;
import com.company.card_service.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@Api("小程序曝光统计页面接口")
@RestController
@RequestMapping("api/company/statistics")
public class ApiExposureStatisticsController {

    @Autowired
    EmployeeViewServiceImpl employeeViewService;

    @GetMapping("getStatistics/{employeeId}")
    @ApiOperation("统计访问量")
    public Result getEmployee(@PathVariable Long employeeId){
        EmployeeViewVo employeeViewVo = employeeViewService.getEmployeeView(employeeId);
        return Result.success(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),employeeViewVo);
    }

    @GetMapping("getChartsStatistics/{employeeId}")
    @ApiOperation("返回访问量的折线图集合")
    public Result getChartsStatistics(@PathVariable Long employeeId){
        //返回chartData数据中的x数据和y数据
        ChartResVo chartData = employeeViewService.getChartData(employeeId);//七天的数据
        return Result.success(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),chartData);
    }

    @PostMapping("getStatisticsOfTime/{employeeId}")
    @ApiOperation("查询对应时间的访问量")
    public Result getStatisticsOfTime(@RequestBody(required = false) FormSearchTimeVo formSearchTimeVo, @PathVariable long employeeId) throws ParseException {
        List<historyEmployeeViewDataVo> historyData = employeeViewService.getHistoryData(employeeId, formSearchTimeVo);
        return Result.success(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(),historyData);
    }
}
